<?php
$this->pageTitle = $model->ClassName;
?>

<div style="width:270px;float:left;">
<div id="ProductSortCssID">

<ul id="pstMenu">

<?php 

$list = array(-999);

$children = NewsCategory::model()->findAll(array('condition'=>'ParentID='.$model->id));
if(empty($children)) {
	$children = NewsCategory::model()->findAll(array('condition'=>'ParentID='.$model->ParentID));
} else {
	foreach($children as $cat) {
		$list[] = $cat->id;
	}
}
foreach($children as $cat) {
?>
<li><?php echo CHtml::link($cat->ClassName, array('newsCategory/view','id'=>$cat->id));?></li>
<?php } ?>

</ul>

<script type="text/javascript">
sfHover = function() { 
    var sfEls = document.getElementById("pstMenu").getElementsByTagName("LI");
    for (var i=0; i<sfEls.length; i++) { 
        sfEls[i].onmouseover=function() { 
            this.className+=" sfhover";
        }
        sfEls[i].onmouseout=function() { 
            this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
        }
    }
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

</script>

<br /><br /><br />
</div>
</div>
<div style="width:700px;float:right;margin:0px 0px 50px 0px;">
    <div id="bread">
    <a href="/">首页</a>
    >>
<?php
$father = NewsCategory::model()->findByPk($model->ParentID); 
if($father) {
?>
    <a href="<?php echo Yii::app()->createUrl('newsCategory/view', array('id'=>$model->ParentID));?>"><?php echo $father->ClassName;?></a>
    >>
<?php } ?>
<?php echo $model->ClassName;?>
    </div>
    <div id="main-content">
    <?php 
    $cnt = News::model()->count(array('condition'=>'category_id='.$model->id));
    if($cnt > 0)  {
        $dataProvider=new CActiveDataProvider('News', array(
            'criteria'=>array(
                'condition'=>'category_id='.$model->id,
                'order'=>'date DESC',
            ),
            'pagination'=>array(
                'pageSize'=>10,
            ),
        ));
    } else {

        $dataProvider=new CActiveDataProvider('News', array(
            'criteria'=>array(
                'condition'=>'category_id in (' . join(",", $list) . ')',
                'order'=>'date DESC',
            ),
            'pagination'=>array(
                'pageSize'=>10,
            ),
        ));
    }
    $this->widget('zii.widgets.CListView', array(
        'dataProvider'=>$dataProvider,
        'itemView'=>'_li',
    )); ?>
    </div>
    <div style="clear:both;"></div>
</div>
